#define _DEFAULT_SOURCE 1
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>

int main(int argc, char const *argv[])
{
    int fd = open("test.txt", O_CREAT | O_RDWR, 0644);
    ftruncate(fd, 7);
    char *buf = mmap(NULL, 7, PROT_WRITE, MAP_SHARED, fd, 0);
    buf[0] = 'a';
    buf[1] = 'b';
    buf[2] = 'c';
    buf[3] = 'd';
    buf[4] = 'e';
    buf[5] = 'f';
    buf[6] = '\n';
    munmap(buf, 7);
    close(fd);
    return 0;
}
